package com.gcxy.controller;


import com.gcxy.core.R;
import com.gcxy.dto.agency.AgencyDTO;
import com.gcxy.dto.agency.AgencyPageDTO;

import com.gcxy.service.AgencyService;
import com.gcxy.vo.agency.AgencyAllListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  组织管理前端控制器
 * </p>
 *
 * @author Huang先森
 * @since 2024-07-22
 */

@Api(tags = "组织管理")
@RestController
@RequestMapping("/agency")
public class AgencyController {
    @Resource
    private AgencyService agencyService;

    @ApiOperation("查询所有组织")
    @GetMapping("/getAgencyAllList")
    public R<List<AgencyAllListVO>> getAgencyAllList(){
        return R.Success(agencyService.getAgencyAllList());
    }

    @ApiOperation("根据条件分页查询所有组织")
    @GetMapping("/getAgencyPageByCondition")
    public R<?> getAgencyPageByCondition(@Validated AgencyPageDTO agencyPageDTO){
        return agencyService.getAgencyPageByCondition(agencyPageDTO);
    }

    @ApiOperation("新增组织")
    @PostMapping("/insertAgency")
    public R<?> insertAgency(@RequestBody @Validated AgencyDTO agencyDTO) {
        return agencyService.insertAgency(agencyDTO);
    }

    @ApiOperation("更新组织")
    @PutMapping("/updateAgency")
    public R<?> updateAgency(@RequestBody @Validated AgencyDTO agencyDTO) {
        return agencyService.updateAgency(agencyDTO);
    }
    @ApiOperation("删除组织")
    @DeleteMapping("/deleteAgencyById/{id}")
    public R<?> deleteAgencyById(@PathVariable Integer id) {
        return agencyService.deleteAgencyById(id);
    }

}

